<template>
  <div class="container">
    <el-card header="认证测试">
      <el-form
        :model="formData"
        :rules="$rules"
        ref="formRef"
        class="grid-flex pt-2 pb-2"
        status-icon
        label-width="8rem"
      >
        <el-form-item prop="empname" :label="$language.local('empname')">
          <xy-input v-model="formData.empname"></xy-input>
        </el-form-item>
        <el-form-item prop="bankcardno" :label="$language.local('bankcardno')">
          <xy-number v-model="formData.bankcardno"></xy-number>
        </el-form-item>
        <el-form-item prop="idcardno" :label="$language.local('idcardno')">
          <xy-input v-model="formData.idcardno"></xy-input>
        </el-form-item>
        <el-form-item prop="phone" :label="$language.local('phone')">
          <xy-number v-model="formData.phone"></xy-number>
        </el-form-item>
      </el-form>
      <div class="form-footer pb-2">
        <el-button type="primary" @click="onSubmit">认证一下</el-button>
      </div>
    </el-card>

    <!-- <div v-show="result">
      <xy-input type="textarea" class="mt-2" v-model="result"></xy-input>
    </div> -->
  </div>
</template>

<script>
export default {
  data() {
    return {
      formData: {
        empname: "",
        bankcardno: "",
        idcardno: "",
        phone: "",
      },
      result: "",
    };
  },
  methods: {
    async onSubmit() {
      const valided = await this.$refs.formRef.validate().catch((err) => err);
      if (!valided) {
        return;
      }
      console.log(this.formData);
      const response = await this.$http.post(
        "/api/omm/EmpAudit",
        null,
        this.formData
      );
      console.log(response);
      this.result = response.data.Data;
      if (response.data.Data == "一致") {
        this.$message.success(response.data.Data);
      } else {
        this.$message.error(response.data.Data);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  .el-card {
    width: 62%;
    transform: translateY(-10%);
  }
}
</style>
